# a = 1;
# if a == 1 :
#     a = 0
# elif a == 2:
#     a = 1
# elif a == 3:
#     a = 2

# a = 'zhangsan'
# b = 'ZhangSan'
# print(a==b)

# s=0
# for i in range(5):
#    s=s+i
# print("s={}".format(s))

# x = 1
# y = 2
# maxNum = x if x > y else y
# print (maxNum)

# a, b = eval(input())
# y = a / b
# if b == 0 :
#     print("error")
# else:
#     print("%.2f"%y)
# temp = 1
# if not(temp > 10):
#     print("太冷了！")
# else:
#     print("明天见！")

# x,y,z=1,-1,1
# if x > 0:
#     if y > 0:
#         print("x > 0 and y > 0")
# elif z > 0:
#         print("x < 0 and z > 0")

# Score = eval(input())
# if Score >= 60:
#     print("You passed.")
# else:
#     print("You failed.")

# a, b, c = eval(input())
# if a <= b:
#     if b <= c:
#         print(f"{a},{b},{c}")
#     else:
#         if a <= c:
#             print(f"{a},{c},{b}")
#         else:
#             print(f"{c},{a},{b}")
# else:
#     if a <= c:
#         print(f"{b},{a},{c}")
#     else:
#         if b <= c:
#             print(f"{b},{c},{a}")
#         else:
#             print(f"{c},{b},{a}")

# x = 6
# y = eval(input("请输入一个1~10之间的数字："))
# if y == x:
#     print("你真棒，猜对了！")
# elif y > x:

# score = eval(input())
# if score >= 90:
#     print('A')
# elif score >= 80:
#     print('B')
# elif 70<=score<80:
#     print('C')
# elif score >= 60:
#     print('D')
# elif score >= 0:
#     print('E')
# else:
#     print("erro")

# a = int(input())
# if a % 2 == 0:
#     print(f"{a}是偶数")
# else:
#     print(f"{a}是奇数")

# a, b, c = input().split(" ")
# a = int(a)
# c = int(c)
# if b == '*':
#     val = a * c
#     print(f"{a}{b}{c}={val}")
# elif b == '/':
#     val = int(a / c)
#     print(f"{a}{b}{c}={val}")
# elif b == '%':
#     val = a % c
#     print(f"{a}{b}{c}={val}")
# else:
#     print("Invalid operator")

# s = input()
# s = s.replace(' ','')
# try:
#     print(s, eval(s), sep='=')
# except:
#     print('Invalid operator')

# n = int(input())
# count1 = 0
# count2 = 0
# for i in range(0, n):
#     strs = str(input())
#     year = int(strs[6:10])
#     if year > 2014:
#         count2 += 1
#         print("NO")
#     elif year == 2014:
#         month = int(strs[10:12])
#         if month > 8:
#             count2 += 1
#             print("NO")
#         else:
#             count1 += 1
#             print("YES")
#     else:
#         count1 += 1
#         print("YES")
# print(f"Pass: {count1}; Fail: {count2}")

# num=input("请输入学生成绩：")
# ls=[]
# sum=0
# while num!='':
#      ls.append(num)
#      sum=sum+eval(num)
#      num=input("请输入学生成绩：")
# n=len(ls)
# print('共输入了{}个人的成绩，他们的平均成绩是{:.2f}'.format(n,sum/n))

# number = 25
# isPrime = True
# for i in range(2, number):
#   if number % i == 0:
#     isPrime = False
#     break
# print("i is", i, "isPrime is", isPrime)

# n=3
# a=[0]*n
# for i in range(n):
#     a[i]=[0]*i

# s = 0
# inp1 = [int(x) for x in input().split()]
# for item in inp1:
#     if item > 20:
#         continue
#     s += item
# print(s)

# a = '0123456789'
# b = list(a)
# s = []
# for x in b:
#     if x:
#         s = s + [x]
# print(s)

# x = 0
# for i in range(1, 20, 3):
#     x = x + i
# print(x)

# for ch in "PYTHON STRING":
#     if ch == " ":
#         break
#     print(ch, end = "")
#     if ch == "H":
#         continue

# num = int(input())
# a = num - 1
# while a > 1:
#     if num % a == 0:
#         print("不是素数")
#         break
#     a = a - 1
# else:
#     print("是素数")

# s = 0
# inp1 = [int(x) for x in input().split()]
# for item in inp1:
#     if item > 20:
#         break
#     s += item
# print(s)

# for s in "PythonNCRE":
#     if s == "N":
#         break
#     print(s, end="")

# i, j = 0, 0
# while True:
#     i = i + 1
#     if i > 10:
#         break
#     if i % 2 == 0:
#         continue
#     else:
#         j = j + i
# print(j)

# fruits = ['banana', 'apple', 'mango', 'Pear', 'Grape', 'orange']
# for index in range (len(fruits)):
#     print('当前水果:', fruits[index])

# leapYears = [x for x in range(2000, 3001) if (x % 4 == 0 and x % 100 != 0) or (x % 400 == 0)]
# print("Leap years(2000~3000):", leapYears)

# contacts = [{"name": "Qi Lee", "mobile": 13946253589}, {"name": "Anny Hofman", "mobile": 13651323101}]
# name = input()
# isFound = False
# for people in contacts:
#     if people["name"] == name:
#         isFound = True
#         print(people["mobile"])
#         break
# if not isFound:
#     print("用户不存在")

# n = int(input())
# fact = 1
# i = 1
# while i <= n:
#     fact = fact * i
#     i = i + 1
# print('{}!={}'.format(n, fact))

# sum = 0
# n = 2
# while n <= 100:
#     sum = sum + n
#     n = n + 2
# print(sum)

# n = int(input())
# sum = 1
# for i in range(1, n + 1):
#     if i % 2 == 0:
#         sum = sum * i
# print(sum)

# a = int(input())
# s = 0
# n = 1
# while s < a:
#     s = s + n
#     n = n + 1
# print('{}=1+2+...+{}'.format(s, n - 1))

# st="Hello World!"
# print(st[0:-1])
# a = "3"
# b = "4"
# c = a + b
# print(type(c))
# print(c)

# print(3 > 2>=2)
# _ab = 6
# _Ab = 4

# x = (1, 2, 3, 4)
# x[0] = 5

# print(100//3)

# s = "abcd'12'34"
# print(s[-6:])

# s=0
# for i in range(5):
#    s=s+i
# print("s={}".format(s))

# momthdays=dict(Jan=31,Feb=28,Mar=31,Apr=30)

# s=[1,2,3]
# y=s[3]

# number = 25
# isPrime = True
# for i in range(2, number):
#   if number % i == 0:
#     isPrime = False
#     break
# print("i is", i, "isPrime is", isPrime)

# print(0xA + 0xB)
#
# list1 = [1, 2, 3, 4, 5, 4, 3, 2, 1]
# print(list1[:-1])

# s='hello'
# t=" world"
# s=s+t
# print(s, "/", s[-1], "/", s[2:8])

# print( 0 and 1 or not 2<True )

# x = True
# y = False
# z = False
# print(x or y and z)

# lst=[3,4,5,6,5,4,3]
# lst.remove(3)
# print(lst[0])

# def func(x, y=2, z=3): return x - y - z
#
# squares={x:x*x  for x in range(20)}
# print(squares[12])

# i = 1
# while i + 1:
#     if i > 4:
#         print("%d" % i)
#         i += 1
#         break
#     print("%d" % i)
#     i += 1
#     i += 1

n = int(input())

for i in range(1, 10**n) :
    j = i
    sum = 0
    while i != 0:
        a = i % 10
        i = i // 10
        sum += a**5
    if sum == j:
        print(sum)